// import axios from "axios";

export function download(url){
  let a = document.createElement("a");
  a.href = url;
  a.click();
}

export function downloadPng(url){
    return new Promise(resolve => {
      let canvas = document.createElement('canvas')
      let ctx = canvas.getContext('2d')
      let img = new Image()
      img.crossOrigin = 'Anonymous' //允许跨域
      img.src = url
      img.onload = function() {
        canvas.height = 300
        canvas.width = 300
        ctx.drawImage(img, 0, 0, 300, 300)
        let dataURL = canvas.toDataURL('image/png')
        canvas = null
        resolve(dataURL)
      }
    })
}
